//
//  NetworkCheckTool.m
//  kuaiyi
//
//  Created by Alphts on 16/7/7.
//  Copyright © 2016年 Alphts. All rights reserved.
//

#import "NetworkCheckTool.h"

@implementation NetworkCheckTool

+ (void)checkNetworkWithSuccessBlock:(void (^)())successBlock errorBlock:(void (^)())errorBlock{
    
    Reachability *reach = [Reachability reachabilityWithHostname:@"www.baidu.com"];
    
    reach.reachableBlock = ^(Reachability *reach)
    {
        
         NSLog(@"???%@",[NSThread currentThread]);
        
        dispatch_async(dispatch_get_main_queue(), ^{
            
            if (successBlock) {
                successBlock();
            }
        });
    };
    
    reach.unreachableBlock = ^(Reachability *reach)
    {
        
        dispatch_async(dispatch_get_main_queue(), ^{
            
            if (errorBlock) {
                errorBlock();
            }
        });
    };
    
    [reach startNotifier];
    
}

@end
